package com.meishij.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.meishij.R;
import com.meishij.entry.ShihuaEntry;

import java.util.List;

/**
 * Created by Administrator on 2016/10/12.
 * 我是youngKaka 我的心愿是世界和平
 */

public class ShiHua_Column_Adpater extends RecyclerView.Adapter<ShiHua_Column_Adpater.ViewHolder> {

    private Context context;
    private List<ShihuaEntry.ColumnBean> list;

    public ShiHua_Column_Adpater(Context context, List<ShihuaEntry.ColumnBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);


    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_shihua_column_layout, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Uri parse = Uri.parse(list.get(position).getImg());
        holder.simpleDraweeView.setImageURI(parse);
        holder.itemView.setOnClickListener(list.get(position));
        holder.textView.setText(list.get(position).getName());
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        private final SimpleDraweeView simpleDraweeView;
        private final TextView textView;

        public ViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView = ((SimpleDraweeView) itemView.findViewById(R.id.sdv_shihua_column_pic));
            textView = ((TextView) itemView.findViewById(R.id.tv_shihua_column_title));
        }
    }

}
